package com.example.myapplication.ui.user;

import android.text.TextUtils;
import android.view.View;

import com.bumptech.glide.Glide;
import com.example.myapplication.App;
import com.example.myapplication.R;
import com.example.myapplication.bean.User;
import com.example.myapplication.databinding.ActivityUserinfoBinding;

import cn.project.base.baseui.BaseNormalActivity;

public class UserInfoActivity extends BaseNormalActivity<ActivityUserinfoBinding> {


    @Override
    protected int getLayoutId() {
        return R.layout.activity_userinfo;
    }

    @Override
    protected void initView() {

    }

    User user =null;
    @Override
    protected void initData() {
        mBinding.toolbar.tvTitle.setText("用户信息");
        mBinding.toolbar.rlBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        mBinding.sbPersonDataName.setRightText(App.getInstance().user.getName());
        user = App.getInstance().user;
        setUserinfo();


    }


    private void setUserinfo(){
        if (user !=null){
            if (TextUtils.isEmpty(user.getSex())){
            }else {
                if ("男".equals(user.getSex())){
                    mBinding.sbSettingAuto.setRightText("男");
                }else {
                    mBinding.sbSettingAuto.setRightText("女");
                }
            }
            if (!TextUtils.isEmpty(user.getPhone())){
                mBinding.sbPersonDataPhone.setRightText(user.getPhone());
            }
            if (!TextUtils.isEmpty(user.getName())){
                mBinding.sbPersonDataName.setRightText(user.getName());
            }
            if (!TextUtils.isEmpty(user.getEmail())){
                mBinding.sbPersonEmail.setRightText(user.getEmail());
            }
            if (!TextUtils.isEmpty(user.getHead_url())){
                Glide.with(UserInfoActivity.this).load(user.getHead_url()).into(mBinding.ivPersonDataAvatar);
            }
        }
    }
}